define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, $timeout, GoDialog,T_password,GoPage,Auth) {
		$scope.scope = new Object();
		$scope.info = Auth.get_loginInfo();//要显示用户
		
		$scope.change_password = function() {
			if(!$scope.scope.old) {
				GoDialog.toast("请输入旧密码");
				return;
			}
			if(!$scope.scope.new) {
				GoDialog.toast("请输入新密码");
				return;
			}
			if($scope.scope.againnew!=$scope.scope.new) {
				GoDialog.toast("两次输入密码不一致");
				return;
			}
			T_password.change_password($scope.scope.old, $scope.scope.new, function(data) {
				$scope.success = data;
				if(data.success == true) {
					GoDialog.toast("修改密码成功");
					GoPage.go_states("t-set");//修改完后跳转到t-set页面
				} else
					GoDialog.alert("提示",data.msg);
			});
		};
		
		//清空输入
		$scope.clearInput = function(type){
			if(type==1) $scope.scope.old = "";
			if(type==2) $scope.scope.new = "";
			if(type==3) $scope.scope.againnew = "";
		}
			
		
	}

	controller.$inject = ['$scope', '$timeout', 'GoDialog','T_password','GoPage','Auth'];

	return app.registerController("t_passowrdctrl",controller);
});